﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.Data.DbUtils.DataMapping;
using PMS.Data.Entities.SystemModules;

namespace PMS.Data.EntityMap.SystemModules
{
    /// <summary>
    /// Represents a SystemModule mapping configuration
    /// </summary>
    public partial class SystemModuleMap : PMSEntityTypeConfiguration<SystemModule>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<SystemModule> builder)
        {
            builder.ToTable("sys_module");
            builder.HasKey(module => module.Id);

            builder.Property(module => module.Name).HasMaxLength(128).IsRequired();
            builder.Property(module => module.DisplayName).HasMaxLength(128);
            builder.Property(module => module.ModuleDescription).HasMaxLength(512);
            builder.Property(module => module.ModuleDepth).IsRequired();
            builder.Property(module => module.RouteUrl).HasMaxLength(1024);
            builder.Property(module => module.HtmlIconCSSClass).HasMaxLength(1024);
            builder.Property(module => module.AssignedModuleButtonIds).HasMaxLength(1024);
            builder.Property(module => module.ParentModuleId).IsRequired();
            builder.Property(module => module.DisplayOrder).IsRequired();
            builder.Property(module => module.IsActive).IsRequired();
            builder.Property(module => module.OpenMode).IsRequired();
            builder.Property(module => module.LimitedToStores).IsRequired();

            builder.Ignore(module => module.ModuleButtonIds);
            base.Configure(builder);
        }

        #endregion
    }
}
